<?php
$emailaddresses = array();

$fp = fopen("maillog.txt",'r');
$fp2 = fopen("/tmp/emails.txt", "w+");

$count = 0;

echo "<pre>";

while(!feof($fp) && $count<200){
    $line = fgets($fp);
    
        
    
    if(preg_match("/smtp/", $line)){
        
//        echo htmlentities($line)."\n";
        if(preg_match_all("/to=<([^>]+)>/is", $line, $matches, PREG_SET_ORDER)){
//            print_r($matches);
            if(isset($matches[0][1]) && !preg_match("/proteon/",$matches[0][1]))
            {
                $emailaddresses[] = $matches[0][1];
                fwrite($fp2, $matches[0][1]."\n");
            }
        }
        
    }
//    $count++;
}

fclose($fp);
fclose($fp2);

//$emailaddresses = array_unique($emailaddresses);

//print_r($emailaddresses);

echo "done";
